package cn.wrl.order.service.center;


import cn.wrl.order.pojo.Orders;
import cn.wrl.order.pojo.vo.OrderStatusCountsVO;
import cn.wrl.pojo.IMOOCJSONResult;
import cn.wrl.pojo.PagedGridResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient("foodie-order-service")
@RequestMapping("myorder-api")
public interface MyOrdersService {

    /**
     * 查询用户所有订单
     *
     * @param userId
     * @return
     */
    @GetMapping("order")
    PagedGridResult queryMyOrders(@RequestParam("userId") String userId,
                                  @RequestParam("orderStatus") Integer orderStatus,
                                  @RequestParam("keywords") String keywords,
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @RequestParam(value = "pageSize", required = false) Integer pageSize);

    /**
     * 更新订单状态： 已付款 --> 已发货
     *
     * @param orderId
     */
    @PostMapping("order/delivered")
    void updateDeliverOrderStatus(@RequestParam("orderId") String orderId);


    /**
     * 查询用户单个订单
     *
     * @param userId
     * @param orderId
     * @return
     */
    @GetMapping("order/details")
    Orders queryMyOrder(@RequestParam("userId") String userId,
                        @RequestParam("orderId") String orderId);

    /**
     * 更新订单状态： 确认收货
     *
     * @param orderId
     * @return
     */
    @PostMapping("order/received")
    Boolean updateReceiveOrderStatus(@RequestParam("orderId") String orderId);

    /**
     * 删除订单（逻辑删除）
     *
     * @param userId
     * @param orderId
     * @return
     */
    @DeleteMapping("order")
    Boolean deleteOrderStatus(@RequestParam("userId") String userId,
                              @RequestParam("orderId") String orderId);

    /**
     * 查询用户订单数
     *
     * @param userId
     * @return
     */
    @GetMapping("order/count")
    OrderStatusCountsVO getOrderStatusCounts(@RequestParam("userId") String userId);

    /**
     * 获取订单的动向
     *
     * @param userId
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("order/trend")
    PagedGridResult getOrderTrend(@RequestParam("userId") String userId,
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @RequestParam(value = "pageSize", required = false) Integer pageSize);


    @GetMapping("checkUserOrder")
    IMOOCJSONResult checkUserOrder(@RequestParam("userId") String userId,
                                   @RequestParam("orderId") String orderId);
}
